<?php

namespace App\Models;

use App\Services\Product\ExcelService;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;

class OrderData extends Model{
    
    //生e经订单数据
    protected $table = 'order_datas';

    public $timestamps = false;

    protected $fillable = [
        //订单号
        'order_num',
        //宝贝标题
        'commodity_title',
        //宝贝链接
        'commodity_url',
        //子订单金额
        'sub_order',
        //成交单价
        'trading_univalence',
        //宝贝数量
        'commodity_quantity',
        //子订单金额（折算:邮费、优惠等）
        'sub_order_money',
        //买家旺旺
        'buyer_wangwang',
        //付款时间
        'paid_at',
        //创建时间
        'created_at',
    ];

    public function setPaidAtAttribute($value){
        $value = (new ExcelService)->setColumnValueToDateString($value);
        $this->attributes['paid_at'] = $value;
    }

    public function setCreatedAtAttribute($value){
        $value = (new ExcelService)->setColumnValueToDateString($value);
        $this->attributes['created_at'] = $value;
    }

}
